receiving buffer immediately. set the full flag (BF) and interrupt flag (sspif) of the master receiving buffer to "1 ". After the master CPU detects the full or interrupt mark position 1 of the master receiving buffer, it can read the data in the receiving buffer. Similarly, after the CPU detects that the receiving buffer is full or the interrupt flag is 1, the data in the receiving buffer can be read to complete the communication process. Here, dspic30f6014 is set as the master controller, and
send and receive serial data at the same time, can be used as a host or slave, provide frequency programmable clock, send end interrupt sign, write conflict protection, bus competition protection. The SPI bus has four modes of operation (SP0, SP1, SP2, SP3), the most widely used are SPI0 and SPI3. in order to exchange data with peripherals, the
MCU simulation SPI interface-deep understanding of SPI bus protocol SPI (serial peripheral interfacer serial peripheral interface) is a synchronous serial communication interface launched by Motorola, the serial connection between the microprocessor compaction controller and
I still remember that the first time I used the SPI device was my junior summer vacation. At that time, I bought a wireless module with my teammates and used a single-chip microcomputer for wireless transmission, but the code was not written by myself, although this function was implemented, I still had no idea about SPI at the time. Senior, I felt ashamed to ask how to use
Whether in the network or communication field, as long as it is related to electronics or intelligence, you can find that they all have certain protocols. Now we will introduce the SPI bus protocol. The SPI bus protocol is a commu
SPI bus protocol Introduction 1. Technical Performance
The SPI interface is the serial peripheral interface first proposed by Motorola for full duplex three-line synchronization. It adopts the master-slave mode architecture and supports multi-Slave Mode Applications. Generally, it only supports single master. The clock
(*resume) (struct spi_device *spi); struct device_driver driver;};The Id_table field is used to specify the device name that the driver can drive, and the bus matching function compares the name specified in the id_table with the Modalias field in the Spi_device structure, which matches the success of the match and then departs Spi_ Driver's probe callback function is called t
Through the first article, we already know that the whole SPI drive architecture can be divided into three parts: Protocol driver, general interface layer and controller driver. The controller driver is responsible for the data sending and receiving work at the lowest level, in order to complete the data sending and receiving work, the controller driver needs to complete the following functions:1. Request t
Through the first article, we already know that the whole SPI drive architecture can be divided into three parts: Protocol driver, common interface layer and controller driver. Among them, the controller driver is responsible for the lowest data receiving and dispatching work, in order to complete the data receiving and dispatching, the controller driver needs to complete the following functions:
1. Apply f
below it, and the worker threads will process the message requests one at a time according to the FIFO principle, and after each message transfer, the corresponding SPI_ The complete callback function of the message structure is invoked to notify the Protocol driver of preparing the next frame of data. This is the queue of spi_message. When a worker thread wakes up, the relationship between Spi_master, Spi_message, and Spi_transfer can be described i
pending spi_message structures under Master, and the worker thread will process each of these message requests on a first-in, one-out basis, after each message transfer is complete, corresponding to the Spi_ The complete callback function of the message structure is called to notify the Protocol driver to prepare the next frame of data. This is the spi_message of the queue. When a worker thread wakes up, the relationship between Spi_master, Spi_messa
cheaper, the Philips laboratory in the Netherlands developed 'inter-integrated circuit', IIC or IIC, A bus protocol that uses only two wires to connect all peripheral chips. The initial standard defined bus speed was 100 kbps. Several revisions were made, mainly in 1995 kbps and 400 1998 Mbps in 3.4.
There are indications that the
The last 2 weeks have been debugging IIC and SPI bus equipment, here record 2 kinds of bus, in case of forgetting.
One IIC Bus
The abbreviation of I2c--inter-ic serial Bus is the serial transmission bus between chips introduced by
software architecture SPI Controller Driver
The SPI Controller does not care about the specific functions of the device, it is only responsible for the upper layer protocol drive prepared data according to the SPI bus timing requirements sent to the
that the initial level of the clock signal is high. In addition, we use Cpha to indicate that the clock along the sampled data, Cpha to 0 means that the first clock changes along the sampled data, while the Cpha of 1 indicates that the second clock changes along the edge to sample data. The kernel uses a combination of Cpol and cpha to represent the working mode that the current SPI requires:
Cpol=0,cpha=1 Mode 0
Cpol=0,cpha=1 Mode 1
Now that we know the protocol, we can start to look at the SPI driver code in Linux kenerl. There are many struct in the code, so let's take a look at the main struct first, in this way, we can better understand the driver. Mainly include/Linux/SPI. h
The first is the communication interface between the SPI host and t
communication can be achieved between the master and slave devices. When there are multiple slave devices, you can also add a select line from the device.If you use a general IO port to simulate the SPI bus, you must have an output port (SDO), one input port (SDI), and the other port depends on the type of the implemented device, if you want to implement a Master/Slave Device, You need to input the output
communication. In its protocol system, the transmission of data will bring the device address of the destination device, so the device network can be implemented.If you use a universal IO port to simulate the I²C bus and achieve bidirectional transmission, one input output (SDA) is required, and an output (SCL) is required. (Note: The data of i²c is relatively small, the description may be very incomplete)
is a low level, and 1 indicates that the initial level of the clock signal is a high level. In addition, we use Cpha to indicate that at that clock along the sampled data, Cpha 0 indicates that the first clock changes along the sampling data, while the Cpha 1 means to sample the data along the second clock change. The kernel uses a combination of Cpol and cpha to represent the working mode that the current SPI requires: Cpol=0,cpha=1 mode 0 cpol=0
is a low level, and 1 indicates that the initial level of the clock signal is a high level. In addition, we use Cpha to indicate that at that clock along the sampled data, Cpha 0 indicates that the first clock changes along the sampling data, while the Cpha 1 means to sample the data along the second clock change. The kernel uses a combination of Cpol and cpha to represent the working mode that the current SPI requires: Cpol=0,cpha=1 mode 0 cpol=0
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.